package com.furns.utils;

import javax.servlet.http.HttpServletRequest;

import java.time.LocalDateTime;

/**
 * @Author LuoJiaCheng
 * @ID 2240129126
 * @Version 1.0
 */
public class WebUtils {


    //定义一个文件上传的路径
    public static String FURN_IMG_DIRECTORY="assets/images/product-image";
    /**
     * 判断请求是不是Ajax请求
     * @param request
     * @return
     */
    public static boolean isAjaxRequest(HttpServletRequest request){
        return "XMLHttpRequest".equals(request.getHeader("X-Requested-With"));
    }

    //将上传文件按年月日分
    public static String getYearMothDay(){
        LocalDateTime ldt = LocalDateTime.now();
        int year = ldt.getYear();
        int monthValue = ldt.getMonthValue();
        int dayOfMonth = ldt.getDayOfMonth();
        String yearMonthDay = year+"/"+monthValue+"/"+dayOfMonth+"/";
        return yearMonthDay;

    }
}
